package com.teamb6.shop.controller.admin;
import com.teamb6.shop.domain.SearchIndentResponse;
import com.teamb6.shop.service.IndentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/indent")
public class IndentController {
    @Autowired
    private IndentService indentService;
    @GetMapping
    public String indentPage(){
        return "indent-list";
    }
    //未发货订单的地址信息
    @GetMapping("/search")
    @ResponseBody
    public SearchIndentResponse searchIndentResponse(@RequestParam ("pageNum")Integer pageNum,@RequestParam("pageSize")Integer pageSize){
        return  indentService.searchIndent(pageNum,pageSize);
    }
    //未发货订单的商品信息
    @GetMapping("/searchgoods")
    @ResponseBody
    public SearchIndentResponse searchGoodsResponse(@RequestParam("pageNum")Integer pageNum,@RequestParam("pageSize") Integer pageSize){
        return indentService.findgoods(pageNum,pageSize);
    }
    //未收货订单的商品信息
    @GetMapping("/searchgoods1")
    @ResponseBody
    public SearchIndentResponse searchGoodsResponse1(@RequestParam("pageNum")Integer pageNum,@RequestParam("pageSize") Integer pageSize){
        return indentService.findgoods1(pageNum,pageSize);
    }
    @GetMapping("/show")
    public String show(){
        return "indent-list2";
    }
    @GetMapping("/search1")
    @ResponseBody
    public SearchIndentResponse searchIndentResponse1(@RequestParam("pageNum") Integer pageNum,@RequestParam("pageSize") Integer pageSize){
        return indentService.searchIndent1(pageNum,pageSize);
    }
//    //删除单个订单
//    @DeleteMapping("/delete")
//    public boolean  deleteIndent(@RequestParam("id") Integer id){
//        int deletedata = IndentService.delectIndent(id);
//            return deletedata>0;
//
//    }
    //修改发货信息
    @RequestMapping("/delivery")
    public String  updateIssend(@RequestParam("id") Integer id){
        int updatedata = indentService.uodateIssent(id);
        if(updatedata>0)
          return "indent-list";
        return "redirect: 404";
    }



}
